import { defineConfig } from "vite";
import uni from "@dcloudio/vite-plugin-uni";
import AutoImport from "unplugin-auto-import/vite";
import path from "path";

// https://vitejs.dev/config/
export default defineConfig({
  plugins: [
    uni(),
    AutoImport({
      imports: [
        "vue",
        "pinia",
        {
          "uview-pro": ["http"]
        },
        {
          "@/use/storage": [
            "useStorage"
          ]
        },
        {
          "@dcloudio/uni-app": [
            "onLaunch",
            "onShow",
            "onHide",
            "onError",
            "onUniNViewMessage",
            "onUnhandledRejection",
            "onPageNotFound",
            "onThemeChange",
            "onLastPageBackPress",
            "onExit",
            "onInit",
            "onLoad",
            "onReady",
            "onUnload",
            "onResize",
            "onPullDownRefresh",
            "onReachBottom",
            "onTabItemTap",
            "onShareAppMessage",
            "onPageScroll",
            "onNavigationBarButtonTap",
            "onBackPress",
            "onNavigationBarSearchInputChanged",
            "onNavigationBarSearchInputConfirmed",
            "onNavigationBarSearchInputClicked",
            "onShareTimeline",
            "onAddToFavorites"
          ]
        }
      ],
      resolvers: [],
      eslintrc: {},
      // 是否在 vue 模板中自动导入
      vueTemplate: true,
      // 指定自动导入函数TS类型声明文件路径 (false:关闭自动生成)
      dts: path.resolve(__dirname, "types/auto-imports.d.ts")
      // dts: false
    })
  ],
  css: {
    preprocessorOptions: {
      scss: {
        // 取消sass废弃API的报警
        silenceDeprecations: ["legacy-js-api", "color-functions", "import"]
      }
    }
  }
});

